/*
  Copyright 1996-2003
  Simon Whiteside

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

  $Id: ExecutableContext.java,v 1.3 2003/02/24 18:10:53 simkin_cvs Exp $
*/

package simkin;	

/**
 * This class stores info about the current execution context - such the name of the current script and the line number being executed.
 * You should create a new one of these for each invocation of a chain of calls into the Simkin interpreter.
 * e.g.
 * <pre>
 * ExecutableContext ctxt=new ExecutableContext(m_Interpreter);
 * obj.method("onClick",args,ctxt);
 * </pre>
 */

public class ExecutableContext {
    public ExecutableContext(Interpreter interp){
	m_Interpreter=interp;
    }
    /**
     * Returns the interpreter associated with this context 
     * @return the interpreter associated with this context 
     */
    public Interpreter getInterpreter(){
	return m_Interpreter;
    }
    /** 
     * puts a new stack frame on the stack 
     * @param frame a new stack frame
     */
    public void pushStackFrame(StackFrame frame){
	if (m_TopFrame!=null)
	    frame.setParentFrame(m_TopFrame);
	m_TopFrame=frame;
    }
    /**
     * takes the top stack frame off the stack 
     */
    public void popStackFrame(){
	if (m_TopFrame!=null){
	    StackFrame parent=m_TopFrame.getParentFrame();
	    m_TopFrame.setParentFrame(null);
	    m_TopFrame=parent;
	}
    }
    /**
     * This method returns the current StackFrame active in the interpreter
     * @return the top of the Simkin stack 
     */
    public StackFrame getTopFrame(){
	return m_TopFrame;
    }
    /** Interpreter being used in this context */
    private Interpreter m_Interpreter;
    /** Top of the Simkin stack */
    private StackFrame m_TopFrame;
}
